<!-- extends表明此页面继承自 base.html 文件 -->
{% extends "acdlist/base.html" %}
{% load static %}
<!-- 写入 base.html 中定义的 title -->
{% block title %}
学术主页板块
{% endblock title %}
<!-- 写入 base.html 中定义的 content -->

{% block content %}
<style>
    .floor-rank-total-item {
    padding: 24px 0;
    padding-top: 24px;
    padding-right: 0px;
    padding-bottom: 24px;
    padding-left: 0px;
    border-bottom: 1px solid #e9e9e9;
    border-bottom-width: 1px;
    border-bottom-style: solid;
    border-bottom-color: rgb(233, 233, 233);
}
.total-content {
    display: flex;
}
 .number {
    display: inline-block;
    width: 24px;
    height: 24px;
    line-height: 24px;
    text-align: center;
    font-size: 20px;
    font-family: PingFangSC-Regular,PingFang SC;
    font-weight: 400;
    color: #999aaa;
}


.total-box {
    -webkit-box-flex: 1;

    flex: 1;
    flex-grow: 1;
    flex-shrink: 1;
    flex-basis: 0%;


    display: flex;
    -webkit-box-pack: justify;

    justify-content: space-between;
}
dl, ol, ul {
    margin-top: 0;
    margin-left: 1rem;
    margin-bottom: 1rem;
}
.right-box {
    padding-right: 8px;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    -webkit-box-align: end;
    -ms-flex-align: end;
    align-items: flex-end;
    -webkit-box-flex: 0;
    -ms-flex: none;
    flex: none;
    flex-grow: 0;
    flex-shrink: 0;
    flex-basis: auto;
}
</style>
<div class="container h-100">
    <br>
    <h3>全站学术列表</h3>
    <div class="floor-rank-total">
 {%for acd,valu in dic.items%}
        <div class="floor-rank-total-item">

                <div class="total-content">

                    <span class = 'number'>{{forloop.counter}}</span>
                    <a target="_blank" href="../academy/{{acd.user_id}}">

                        <img src="{{acd.pic}}" alt="Big Boat" width="50" height="80">

                    </a>
                    <div class="total-box">
                        <dl>
                            <dd>
                                <a target="_blank" href="../academy/{{acd.user_id}}" id='forloop.counter'>
                        {{acd.user_id}}
                    </a>
                            </dd>
                            <dt style="margin-top: 20px;">
                                专业
                                <span style="margin-left: 8px; margin-right: 24px;">
                                   {{acd.major}}
                                </span>
                                更新时间
                                <span style="margin-left: 8px; margin-right: 24px;">
                                   {{acd.update_time}}
                                </span>
                                粉丝数
                                <span style="margin-left: 8px; margin-right: 24px;" id='{{forloop.counter}}'>
                                   {{acd.fans_num}}
                                </span>
                                {% if request.session.username %}
                                {%if acd.user_id != username%}

                                <input type="button" id='{{forloop.counter}}0' value="{{valu}}" onclick="setName('{{acd.user_id}}','{{forloop.counter}}','{{forloop.counter}}0')">
                                <script>

<!--alert({{data}}[{{forloop.counter}}0]);-->

<!--var v ={{data}}[{{forloop.counter}}0];-->
<!--var temp=(v==1?"关注":"取消关注");-->
<!--document.getElementById('{{forloop.counter}}0').value(temp);-->


</script>
                                {%endif%}
                                {%endif%}
                            </dt>
                        </dl>
                        <div class="right-box">

                        </div>

                    </div>



</div>
      </div>
     {% endfor %}
        </div>
        </div>

<script>

function setName(name,id,inputid){
     var item=document.getElementById(inputid);
     var flag;
     if(item.value=="关注"){
     flag=1;
     }
     else{
     flag=0;
     }
    $(document).ready(function(){{
    $.ajax({
        url:"look_button",
        type:"POST",
        data:{
            user: "{{username}}",
            follow_name:name,
            flag:flag
        },
        cache:false,
        success: function(data){
               console.log("123");
            $("#"+id).html(data['fans_num']);
        },
        error: function(xhr){
            console.log(xhr);
        }
    });

  };
});
var item=document.getElementById(inputid);
               console.log(inputid);
if (item.value=="取消关注"){
item.value = "关注";
}
else{
item.value = "取消关注";
}
}

</script>
<script>
function setvalues(id){
alert({{data}}[id]);
var v ={{data}}[id];
var temp=(v==1?"关注":"取消关注");
document.getElementById(id+'0').value(temp);
}

</script>


{% endblock content %}